package com.yunwaikeji.gy_tool_library.utils;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcelable;
import android.util.SparseArray;

import androidx.fragment.app.Fragment;

import java.io.Serializable;
import java.util.ArrayList;

public class GYArgumentsUtils {
    public static GYArgumentsUtils newBuilder() {
        return new GYArgumentsUtils();
    }

    private final Bundle bundle = new Bundle();

    public GYArgumentsUtils setInt(String key, int value) {
        bundle.putInt(key, value);
        return this;
    }

    public GYArgumentsUtils setIntArray(String key, int[] value) {
        bundle.putIntArray(key, value);
        return this;
    }

    public GYArgumentsUtils setIntegerArrayList(String key, ArrayList<Integer> value) {
        bundle.putIntegerArrayList(key, value);
        return this;
    }

    public GYArgumentsUtils setString(String key, String value) {
        bundle.putString(key, value);
        return this;
    }

    public GYArgumentsUtils setStringArray(String key, String[] value) {
        bundle.putStringArray(key, value);
        return this;
    }

    public GYArgumentsUtils setStringArrayList(String key, ArrayList<String> value) {
        bundle.putStringArrayList(key, value);
        return this;
    }

    public GYArgumentsUtils setSerializable(String key, Serializable value) {
        bundle.putSerializable(key, value);
        return this;
    }

    public GYArgumentsUtils setBoolean(String key, boolean value) {
        bundle.putBoolean(key, value);
        return this;
    }

    public GYArgumentsUtils setBooleanArray(String key, boolean[] value) {
        bundle.putBooleanArray(key, value);
        return this;
    }

    public GYArgumentsUtils setParcelable(String key, Parcelable value) {
        bundle.putParcelable(key, value);
        return this;
    }

    public GYArgumentsUtils setParcelableArray(String key, Parcelable[] value) {
        bundle.putParcelableArray(key, value);
        return this;
    }

    public GYArgumentsUtils setParcelableArrayList(String key, ArrayList<? extends Parcelable> value) {
        bundle.putParcelableArrayList(key, value);
        return this;
    }

    public GYArgumentsUtils setSparseParcelableArray(String key, SparseArray<? extends Parcelable> value) {
        bundle.putSparseParcelableArray(key, value);
        return this;
    }

    public GYArgumentsUtils setByte(String key, byte value) {
        bundle.putByte(key, value);
        return this;
    }

    public GYArgumentsUtils setByteArray(String key, byte[] value) {
        bundle.putByteArray(key, value);
        return this;
    }

    @SuppressLint("NewApi")
    public GYArgumentsUtils setBinder(String key, IBinder value) {
        bundle.putBinder(key, value);
        return this;
    }

    public GYArgumentsUtils setAll(Bundle bundle) {
        bundle.putAll(bundle);
        return this;
    }

    public void build(Fragment fragment) {
        fragment.setArguments(bundle);
    }
}
